package com.example.consumer.controller;

import com.example.consumer.config.GirlConfigProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 王杨帅
 * @create 2018-09-14 10:09
 * @desc
 **/
@RequestMapping(value = "/test")
@RestController
@Slf4j
@RefreshScope
public class TestController {

    @GetMapping(value = "/test01")
    public String test01() {
        String info = "eureka客户端测试";
        log.info(info);
        return info;
    }

    /**
     * 获取远程仓库的配置信息
     */
    @Value("${env}")
    private String env;

    @GetMapping(value = "/env")
    private String env() {
        log.info(env);
        return "远程git仓库的env配置为：" + env;
    }

    @Autowired
    private GirlConfigProperties girlConfigProperties;

    @GetMapping(value = "/girl")
    public String girl() {
        log.info(girlConfigProperties.toString());
        return "name: " + girlConfigProperties.getName() + " age: " + girlConfigProperties.getAge();
    }

}

